using System.Runtime.Serialization;
namespace Game.ExtensibleObjects
{
    [DataContract(Namespace = "game")]
    public class ExtensibleObject
    {
        [DataMember(Name = "Extensions")]
        public ReadOnlyExtensionCollection _extensions;

        public ExtensibleObject()
            : this(new ReadOnlyExtensionCollection())
        {
        }

        public ExtensibleObject(ReadOnlyExtensionCollection extensions)
        {
            _extensions = extensions;
        }

        [OnDeserialized]
        public void OnDeserializedE(StreamingContext c)
        {
            if (_extensions == null)
            {
                _extensions = new ReadOnlyExtensionCollection();
            }
        }

        public ReadOnlyExtensionCollection Extensions 
        {
            get { return _extensions; } 
        }
    }
}